package com.source.quartz.utils;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @Author wengqy
 * @Date 2020/12/16
 */
public class CallableDemo   {

    public static void main(String[] args) {

        MyThread  myThread  = new MyThread();
        FutureTask futureTask = new FutureTask(myThread);
         Thread  thread   = new Thread(futureTask,"AA");
        thread.start();
        try {
            String  resStr = (String) futureTask.get();
            System.out.println(resStr);
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }finally {

        }

    }

}




class MyThread implements Callable<String> {
    @Override
    public String call() throws Exception {
        System.out.println(Thread.currentThread().getName()+"---------------");
        return "callable is   called ......";
    }
}

